![]() ![]() ![]() |
i
is established by the identity
&*(reverse_iterator(i)) == &*(i - 1).This mapping is dictated by the fact that while there is always a pointer past the end of an array, there might not be a valid pointer before the beginning of an array.
Two reverse iterator adapters exist, one for bidirectional iterator and one for random access iterators. ReverseBidirectionalIterator api, ReverseRandomIterator api .
while (first != last) *result++ = *first++;causes a range
[first,last)
to be copied into a range
starting with result
.
The same code with result
being an insert iterator will
insert corresponding elements into the container.
This device allows all of the copying algorithms in the library to work
in the insert mode instead of the regular overwrite mode.
An insert iterator is constructed from a container and possibly one of
its iterators pointing to where insertion takes place if it is neither
at the beginning nor at the end of the container.
Insert iterators satisfy the requirements of output iterators.
operator*
returns the insert iterator itself.
The assignment put(Object x)
is defined on insert
iterators to allow writing into them, it inserts x
right before
where the insert iterator is pointing.
In other words, an insert iterator is like a cursor pointing into the
container where the insertion takes place.
BackInsertIterator api inserts elements at the end of a container, FrontInsertIterator api inserts elements at the beginning of a container, and InsertIterator api inserts elements where the iterator points to in a container.
EnumerationIterator
implements the Enumeration
interface.
This means that any forward range can be passed on to methods which expect
an Enumeration
by code like this.
new SequenceInputStream(new EnumerationIterator(vec.begin(), vec.end()));
![]() ![]() ![]() |